package com.ys.erp.stage_shop_service.controller;

import com.ys.erp.framework.annotation.CheckEmpLogin;
import com.ys.erp.framework.annotation.ResponseResult;
import com.ys.erp.framework.annotation.StageLoginEmp;
import com.ys.erp.framework.bean.dto.StageEmpDTO;
import com.ys.erp.stage_shop_service.bean.condition.ShopCondition;
import com.ys.erp.stage_shop_service.bean.vo.ZfbSeparateAccountSettingVO;
import com.ys.erp.stage_shop_service.service.ShopService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author minamiyama
 * @date 2025/6/18 14:20
 */
@ResponseResult
@RestController
@RequiredArgsConstructor
@RequestMapping("/manage/shop")
@Tag(name = "店铺相关接口", description = "店铺相关接口")
public class ShopController {

    private final ShopService shopService;

    /**
     * 更新店铺支付宝分账设置
     */
    @PutMapping("/updateZfbSeparateAccountSetting")
    @Operation(summary = "更新店铺支付宝分账设置", description = "更新店铺的支付宝账户、分账比例和是否开启分账设置")
    @CheckEmpLogin
    public void updateZfbSeparateAccountSetting(@Valid @RequestBody ShopCondition.UpdateZfbSeparateAccountCon con,
                                                @StageLoginEmp StageEmpDTO empDto) {
        if (!"hz0".equals(empDto.getShopCode())) {
            return;
        }
        shopService.updateZfbSeparateAccountSetting(empDto, con);
    }

    /**
     * 查询店铺支付宝分账设置
     */
    @GetMapping("/getZfbSeparateAccountSetting")
    @Operation(summary = "查询店铺支付宝分账设置", description = "获取店铺的支付宝账户、分账比例和是否开启分账设置，用于反显")
    @CheckEmpLogin
    public ZfbSeparateAccountSettingVO getZfbSeparateAccountSetting(@RequestParam String shopCode,
                                                                   @StageLoginEmp StageEmpDTO empDto) {
        if (!"hz0".equals(empDto.getShopCode())) {
            shopCode = empDto.getShopCode();
        }
        return shopService.getZfbSeparateAccountSetting(shopCode);
    }
}
